import Vue from 'vue'
import App from './App.vue'
// 局部引入组件
//import '@/plugins/element.js'
import 'font-awesome/css/font-awesome.min.css'
//import axios from 'axios'
import router from './router'

// V4 引入
import echarts from 'echarts';
// 或者按需引入
// import echarts from 'echarts/lib/echarts';

// v5 引入
// import * as echarts from 'echarts';
// Object.defineProperties(Vue.prototype, {
//   echarts: { get: () => echarts }
// });
// 按需引入
// import * as echarts from 'echarts/lib/echarts';

//Vue.prototype.axios = axios;

import axios from '@/utils/service'
Vue.prototype.axios = axios;
Vue.prototype.echarts = echarts;

// 全局引入
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
Vue.use(ElementUI);

  // 引入导出Excel表格依赖
  import fileSaver from "file-saver";
  import XLSX from "xlsx";
  Vue.prototype.fileSaver = fileSaver;
  Vue.prototype.XLSX = XLSX;

// 路由导航守卫
router.beforeEach((to,from,next)=>{
   if(!localStorage.getItem('username')){
      if(to.path !== '/login'){
           next('/login')
      }else{
           next()
      }
   }else{
      next()
   }
})




new Vue({
  render: h => h(App),
  router,
}).$mount('#app')
